package com.eam.asset.assetApplication.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.eam.asset.assetApplication.domain.DisposalCategory;
import com.eam.asset.assetApplication.dto.DisposalCategoryDto;
import com.eam.asset.assetApplication.mapper.DisposalCategoryMapper;
import com.eam.asset.assetApplication.service.IDisposalCategoryService;
import com.eam.asset.category.util.CategoryUtil;
import com.eam.common.constant.Constants;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class DisposalCategoryServiceImpl extends ServiceImpl<DisposalCategoryMapper, DisposalCategory> implements IDisposalCategoryService {

    @Override
    public List<DisposalCategoryDto> getDisposalCategoryList() {
        LambdaQueryWrapper<DisposalCategory> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(DisposalCategory::getStatus, Constants.ZERO);
        List<DisposalCategory> disposalCategories = baseMapper.selectList(queryWrapper);
        if (ObjectUtils.isEmpty(disposalCategories)) return null;
        return disposalCategories.stream().map(CategoryUtil::DtoTransform).collect(Collectors.toList());
    }
}
